package com.huacai.framework.config;

import com.huacai.framework.interceptor.DemoEnvironmentInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private DemoEnvironmentInterceptor demoEnvironmentInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 演示环境拦截器
        registry.addInterceptor(demoEnvironmentInterceptor)
                .addPathPatterns("/**") // 拦截所有路径
                .excludePathPatterns("/login", "/logout", "/captchaImage"); // 排除登录等必要接口
    }
}
